//
//  TYHomeFunctionFirstCell.m
//  爱鲜蜂
//
//  Created by 李田 on 16/11/8.
//  Copyright © 2016年 tianyao. All rights reserved.
//

#import "LBHomeFunctionFirstCell.h"
#import "LBBtnView.h"
#import "LBActivityModel.h"
@interface LBHomeFunctionFirstCell ()<SDCycleScrollViewDelegate>

@end

@implementation LBHomeFunctionFirstCell
- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    //    MARK: 设置背景颜色
    self.backgroundColor = [UIColor whiteColor];
}

-(void)setImageArr:(NSMutableArray *)imageArr{
    if (imageArr == nil) {
            return;
    }
    SDCycleScrollView *cycleScrollV = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil];
    cycleScrollV.imageURLStringsGroup = imageArr;
    [self.contentView addSubview:cycleScrollV];

    
    
    //    btnV.backgroundColor = [UIColor redColor];
    //    MARK: 布局
    [cycleScrollV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.contentView);
        make.height.mas_equalTo(160);
    }];
    

}


 -(void)setImageDataArray:(NSMutableArray<LBActRowsModel *> *)imageDataArray{
     if (imageDataArray ==nil) {
         return;
     }
     NSMutableArray *titleArr = [NSMutableArray array];
     //    MARK: 创建btnView
     NSMutableArray *imageNameArr = [NSMutableArray array];
     for(NSInteger i = 0; i < imageDataArray.count; i++){
         LBActRowsModel *model = imageDataArray[i];
         [titleArr addObject:model.activity.name];
         [imageNameArr addObject:model.activity.img];
     }
     NSArray *imageArr = @[@"01", @"02", @"03", @"04"];
     
     LBBtnView *btnV = [[LBBtnView alloc] initWithImageNameArr:imageArr titleArr:titleArr];
     btnV.liTianOperation  = YES;
     [self.contentView addSubview:btnV];
     
     [btnV mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.bottom.right.equalTo(self.contentView);
         make.height.mas_equalTo(80);
     }];
 }

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{


}

#pragma mark -自定义button
- (void)createButtonWithImageName: (NSString *)imageName title: (NSString *)title tag: (NSString *)tag{
    //    MARK: 创建一个按钮
    UIButton *btn = [[UIButton alloc] init];
    //    MARK: 添加到cell中
    [self.contentView addSubview:btn];
    //    MARK: 生成一个图片和文字混合的NSAttributedString（图文混排）
    NSAttributedString *str = [NSAttributedString cz_imageTextWithImage:[UIImage imageNamed:imageName] imageWH:44 title:title fontSize:12 titleColor:[UIColor blackColor] spacing:7];
    //    MARK: 设置按钮的nsattributed属性
    [btn setAttributedTitle:str forState:UIControlStateNormal];
    //    MARK: 设置按钮的大小
    [btn sizeToFit];
    //    MARK: 设置按钮的自动换行
    btn.titleLabel.numberOfLines = 0;
    //    MARK: 设置按钮的文本对齐方式
    btn.titleLabel.textAlignment = NSTextAlignmentCenter;
    //    MARK: 设置按钮的点击事件
    [btn addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

#pragma mark - btn 的点击事件
- (void)btnClickAction: (UIButton *)btn{

    
    
}
#pragma mark - 布局
- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    
    
    
}

@end
